package com.btkjgc.utils;

import java.util.List;

import com.btkjgc.models.AdminUser;

public class FtlOperationUtil {
 

	public static boolean isNull(Object obj) {
		return (obj == null) || ("".equals(obj));
	}

	@SuppressWarnings("rawtypes")
	public static boolean exist(String selectHql, String index) {
		try {
			if (!isNull(index)) {
				List list = HibernateUtil.executeQueryList(selectHql,
						new String[] { index });
				return list.size() > 0;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

	@SuppressWarnings("unchecked")
	public static String getAdminNameByAdminId(Integer id) {
		try {
			String hql = "from AdminUser where id=" + "'" + id + "'";
			List<AdminUser> adminUserInfos = HibernateUtil.executeQueryList(hql,
					null);
			for (AdminUser e : adminUserInfos) {
				return e.getUsername();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}

	public static String getStringType(String intType) {
		String ret = "";
		try {
			if (!FtlOperationUtil.isNull(intType)) {
				String[] intT = intType.split(",");
				int length = intT.length;
				for (int i = 0; i < length; i++) {
					String tString = DataDisplayUtil.getTypeName(3);
					ret += DataDisplayUtil.getType(Integer.valueOf(intT[i]),
							tString);
					if (i < (length - 1)) {
						ret += "，";
					}
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	 
 
}
